<?php echo $html->link('Thêm nhóm con',array('controller'=>'nhomhps','action'=>'themnhom',$idctdt,$idnhom))?>
<br>
<?php echo $html->link('Xóa nhóm',array('controller'=>'nhomhps','action'=>'xoanhom',$idctdt,$idnhom))?>
<div id='tabs'>
<ul>
	<li><a href="#tabs1">Cập nhật thông tin nhóm</a></li>
	<li><a href="#tabs2">Môn tham gia nhóm</a></li>
	<li><a href="#tabs3">Chi tiết môn nhóm</a></li>
</ul>
<div id='tabs1'>
<?php echo $this->Form->create('Nhomhp',array('url'=>array('controller'=>'nhomhps','action'=>'luunhomhp',$idctdt,$idnhom)));?>
	<fieldset>
		<legend><?php __('Sửa nhóm'); ?></legend>
	<?php
		echo $this->Form->input('id',array('value'=>$this->data['Nhomhp']['id']));
		echo $this->Form->input('tenNhom',array('label'=>'Tên nhóm','value'=>$this->data['Nhomhp']['tenNhom']));
		echo $this->Form->input('tongTC',array('label'=>'Tổng số tín chỉ','value'=>$this->data['Nhomhp']['tongTC']));
		echo $this->Form->input('batBuoc',array('label'=>'Bắt buộc','value'=>$this->data['Nhomhp']['batBuoc']));
	?>
	</fieldset>
<?php echo $this->Form->end(__('Lưu', true));?>
</div>

<div id='tabs2'>
<?php echo $form->create('Nhomhp',array('url'=>array('controller'=>'nhomhps','action'=>'luumonnhom',$idctdt,$idnhom)));?>
<div>
<?php echo $this->Form->input('listmonchua', array('id'=>'listmonchua','label'=>'Môn chưa thuộc nhóm','type' => 'select', 'multiple' => 'multiple','options' =>$mons));?>
</div>
<?php echo $form->button('  >>  ',array('id'=>'buttonthem'));?>
<?php echo $form->button('  <<  ',array('id'=>'buttonxoa'));?>
<div>
<?php echo $this->Form->input('listmondaco', array('id'=>'listmondaco','label'=>'Môn thuộc nhóm','type' => 'select', 'multiple' => 'multiple','options' =>$nhom));?>
</div>
<div id='dsco'>
<?php
foreach ($nhom as $key => $value)
{
	echo $form->input('dsco',array('name'=>'data[Nhomhp][dsco]['.$key.']','value'=>$key,'type'=>'hidden'));
} 
?>
</div>
<div id='dschua'>
<?php
foreach ($mons as $key => $value)
{
	echo $form->input('dsco',array('name'=>'data[Nhomhp][dschua]['.$key.']','value'=>$key,'type'=>'hidden'));
} 
?>
</div>
<div id=dsmonxoa>
</div>
<div id=dsmonthem>
</div>
<?php echo $form->end('Lưu');?>
<div id='div_id'>
</div>

</div>

<div id='tabs3'>
<?php echo $form->create('Nhomhp',array('url'=>array('action'=>'luuchitietmon',$idctdt,$idnhom)));?>
<table>
<tr>
<td>STT</td>
<td>Tên môn</td>
<td>Bắt buộc</td>
<td>Môn tiên quyết</td>
</tr>
<?php
$stt=1;
 foreach ($monthamgianhoms as $monthamgianhom):?>
 <?php 
 	$monctdt = $monctdts;
 	unset($monctdt[$monthamgianhom['Mon']['id']]);
 ?>
<tr>
<td><?php echo $stt?></td>
<td><?php echo $monthamgianhom['Mon']['mon']?></td>
<td><?php echo $form->input('batbuoc',array('id'=>'batbuoc','name'=>'data[Nhomhp][batbuoc]['.$monthamgianhom['Monthamgianhom']['id'].']','label'=>false,'type'=>'checkbox','value'=>$monthamgianhom['Monthamgianhom']['batbuoc']));?></td>
<td><?php echo $form->input('tienquyet',array('class'=>'tienquyet','name'=>'data[Nhomhp][tienquyet]['.$monthamgianhom['Monthamgianhom']['id'].']','options'=>$monctdt,'selected'=>$monthamgianhom['Tienquyet']['mon_id'],'label'=>false,'type'=>'select','empty'=>''));?></td>
</tr>
<?php ++$stt;
endforeach; ?>
</table>
<?php echo $form->end('Lưu');?>
</div>

</div>

<script>
$(function() {
	$( "#tabs" ).tabs();
	$(".tienquyet").combobox();
});

$('#buttonthem').live('click',function(){
								$('#listmonchua :selected').each(function(i, selected) {
					                val = $(selected).val();
					                text = $(selected).text();
					                $("#listmonchua option[value='"+ val +"']").remove();
					                $("#listmondaco").append('<option value='+val+'>'+text+'</option>');
					                $("#dsmonxoa #"+val).remove();
					                $("#dsmonthem").append('<INPUT TYPE=HIDDEN id="'+val+'" name=data[Nhomhp][dsmonthem]['+val+'] value='+val+'>');
					  				});
								return false;
								});
$('#buttonxoa').live('click',function(){
	$('#listmondaco :selected').each(function(i, selected) {
        val = $(selected).val();
        text = $(selected).text();
        $("#listmondaco option[value='"+ val +"']").remove();
        $("#listmonchua").append('<option value='+val+'>'+text+'</option>');
        $("#dsmonthem #"+val).remove();
        $("#dsmonxoa").append('<INPUT TYPE=HIDDEN id='+val+' name=data[Nhomhp][dsmonxoa]['+val+'] value='+val+'>');
			});
	return false;
	});
</script>